summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2010-06-18 10:29:15 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2010-06-18 11:03:20 +1000
commit8dc268f32546dc047af8a1b61c4cba56dc6e22ec (patch)
treeb439a1f7995e6c72ff0597f61be2905e402e5219
parenta23facb9e2fcf88208be1c7357ec0d13de29582c (diff)
Remove command queue property setting.
OpenCL 1.1 has deprecated clSetCommandQueueProperty() because it isn't thread safe. Rather than have a difference between the OpenCL 1.0 and 1.1 versions of QtOpenCL, we just implement the OpenCL 1.1 behavior. Out-of-order execution and profiling can be enabled by explicitly calling QCLContext::createCommandQueue().
-rw-r--r--src/opencl/qclcommandqueue.cpp34
-rw-r--r--src/opencl/qclcommandqueue.h3
-rw-r--r--src/opencl/qclcontext.cpp25
-rw-r--r--src/opencl/qclcontext.h3
-rw-r--r--src/opencl/qcldevice.cpp2
-rw-r--r--src/opencl/qclevent.cpp4
-rw-r--r--tests/auto/qcl/tst_qcl.cpp11
7 files changed, 28 insertions, 54 deletions
diff --git a/src/opencl/qclcommandqueue.cpp b/src/opencl/qclcommandqueue.cpp
index e920080..75a56cc 100644
--- a/src/opencl/qclcommandqueue.cpp
+++ b/src/opencl/qclcommandqueue.cpp
@@ -118,8 +118,6 @@ QCLCommandQueue &QCLCommandQueue::operator=(const QCLCommandQueue &other)
/*!
Returns true if this command queue executes commands out of order;
otherwise false if commands are executed in order.
-
- \sa setOutOfOrder()
*/
bool QCLCommandQueue::isOutOfOrder() const
{
@@ -133,27 +131,13 @@ bool QCLCommandQueue::isOutOfOrder() const
}
/*!
- Enables or disables out of order execution of commands according
- to \a enable.
-
- \sa isOutOfOrder()
-*/
-void QCLCommandQueue::setOutOfOrder(bool enable)
-{
- if (!m_id)
- return;
- clSetCommandQueueProperty(m_id, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
- (enable ? CL_TRUE : CL_FALSE), 0);
-}
-
-/*!
Returns true if this command queue will perform profiling on
commands; false otherwise.
Profiling information is made available when a QCLEvent finishes
execution.
- \sa setProfilingEnabled(), QCLEvent::finishTime()
+ \sa QCLEvent::finishTime()
*/
bool QCLCommandQueue::isProfilingEnabled() const
{
@@ -167,22 +151,6 @@ bool QCLCommandQueue::isProfilingEnabled() const
}
/*!
- Enables or disables profiling of commands according to \a enable.
-
- Profiling information is made available when a QCLEvent finishes
- execution.
-
- \sa isProfilingEnabled(), QCLEvent::finishTime()
-*/
-void QCLCommandQueue::setProfilingEnabled(bool enable)
-{
- if (!m_id)
- return;
- clSetCommandQueueProperty(m_id, CL_QUEUE_PROFILING_ENABLE,
- (enable ? CL_TRUE : CL_FALSE), 0);
-}
-
-/*!
\fn cl_command_queue QCLCommandQueue::queueId() const
Returns the native OpenCL command queue identifier for this object.
diff --git a/src/opencl/qclcommandqueue.h b/src/opencl/qclcommandqueue.h
index 825b5ee..58233de 100644
--- a/src/opencl/qclcommandqueue.h
+++ b/src/opencl/qclcommandqueue.h
@@ -66,10 +66,7 @@ public:
bool isNull() const { return m_id == 0; }
bool isOutOfOrder() const;
- void setOutOfOrder(bool enable);
-
bool isProfilingEnabled() const;
- void setProfilingEnabled(bool enable);
cl_command_queue queueId() const { return m_id; }
QCLContext *context() const { return m_context; }
diff --git a/src/opencl/qclcontext.cpp b/src/opencl/qclcontext.cpp
index 8c0e753..03672e6 100644
--- a/src/opencl/qclcontext.cpp
+++ b/src/opencl/qclcontext.cpp
@@ -535,10 +535,17 @@ void QCLContext::setCommandQueue(const QCLCommandQueue &queue)
/*!
Returns the default command queue for defaultDevice(). If the queue
has not been created, it will be created with the default properties
- of in-order execution of commands.
+ of in-order execution of commands, and profiling disabled.
- Out of order execution can be set on the default command queue with
- QCLCommandQueue::setOutOfOrder().
+ Use createCommandQueue() to create a queue that supports
+ out-of-order execution or profiling. For example:
+
+ \code
+ QCLCommandQueue queue =
+ context.createCommandQueue
+ (CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE);
+ context.setCommandQueue(queue);
+ \endcode
\sa commandQueue(), createCommandQueue(), lastError()
*/
@@ -579,8 +586,9 @@ cl_command_queue QCLContext::activeQueue()
}
/*!
- Creates a new command queue on this context for \a device and
- \a properties.
+ Creates a new command queue on this context for \a device with
+ the specified \a properties. If \a device is null, then
+ defaultDevice() will be used instead.
Unlike defaultCommandQueue(), this function will create a new queue
every time it is called. The queue will be deleted when the last
@@ -589,12 +597,15 @@ cl_command_queue QCLContext::activeQueue()
\sa defaultCommandQueue(), lastError()
*/
QCLCommandQueue QCLContext::createCommandQueue
- (const QCLDevice &device, cl_command_queue_properties properties)
+ (cl_command_queue_properties properties, const QCLDevice &device)
{
Q_D(QCLContext);
cl_command_queue queue;
cl_int error = CL_INVALID_VALUE;
- queue = clCreateCommandQueue(d->id, device.deviceId(), properties, &error);
+ if (device.isNull())
+ queue = clCreateCommandQueue(d->id, defaultDevice().deviceId(), properties, &error);
+ else
+ queue = clCreateCommandQueue(d->id, device.deviceId(), properties, &error);
reportError("QCLContext::createCommandQueue:", error);
if (queue)
return QCLCommandQueue(this, queue);
diff --git a/src/opencl/qclcontext.h b/src/opencl/qclcontext.h
index f487690..94cd983 100644
--- a/src/opencl/qclcontext.h
+++ b/src/opencl/qclcontext.h
@@ -92,7 +92,8 @@ public:
QCLCommandQueue defaultCommandQueue();
QCLCommandQueue createCommandQueue
- (const QCLDevice &device, cl_command_queue_properties properties);
+ (cl_command_queue_properties properties,
+ const QCLDevice &device = QCLDevice());
QCLBuffer createBufferDevice
(size_t size, QCLMemoryObject::Access access);
diff --git a/src/opencl/qcldevice.cpp b/src/opencl/qcldevice.cpp
index ada7b3d..99547f3 100644
--- a/src/opencl/qcldevice.cpp
+++ b/src/opencl/qcldevice.cpp
@@ -615,7 +615,7 @@ QCLDevice::FloatCapabilities QCLDevice::halfFloatCapabilities() const
Returns the resolution of the device profiling timer in
nanoseconds.
- \sa QCLEvent::finishTime(), QCLCommandQueue::setProfilingEnabled()
+ \sa QCLEvent::finishTime()
*/
quint64 QCLDevice::profilingTimerResolution() const
{
diff --git a/src/opencl/qclevent.cpp b/src/opencl/qclevent.cpp
index bda9043..79e76f6 100644
--- a/src/opencl/qclevent.cpp
+++ b/src/opencl/qclevent.cpp
@@ -277,7 +277,6 @@ void QCLEvent::waitForFinished()
execution and profiling was enabled on the command queue.
\sa submitTime(), runTime(), finishTime(), isQueued()
- \sa QCLCommandQueue::setProfilingEnabled()
*/
quint64 QCLEvent::queueTime() const
{
@@ -297,7 +296,6 @@ quint64 QCLEvent::queueTime() const
execution and profiling was enabled on the command queue.
\sa queueTime(), runTime(), finishTime(), isSubmitted()
- \sa QCLCommandQueue::setProfilingEnabled()
*/
quint64 QCLEvent::submitTime() const
{
@@ -317,7 +315,6 @@ quint64 QCLEvent::submitTime() const
execution and profiling was enabled on the command queue.
\sa queueTime(), submitTime(), finishTime(), isRunning()
- \sa QCLCommandQueue::setProfilingEnabled()
*/
quint64 QCLEvent::runTime() const
{
@@ -337,7 +334,6 @@ quint64 QCLEvent::runTime() const
execution and profiling was enabled on the command queue.
\sa queueTime(), submitTime(), runTime(), isFinished()
- \sa QCLCommandQueue::setProfilingEnabled()
*/
quint64 QCLEvent::finishTime() const
{
diff --git a/tests/auto/qcl/tst_qcl.cpp b/tests/auto/qcl/tst_qcl.cpp
index 44b8c34..6f887ca 100644
--- a/tests/auto/qcl/tst_qcl.cpp
+++ b/tests/auto/qcl/tst_qcl.cpp
@@ -412,10 +412,12 @@ void tst_QCL::vectorBuffer()
void tst_QCL::eventProfiling()
{
- QCLCommandQueue queue = context.defaultCommandQueue();
- QVERIFY(!queue.isProfilingEnabled());
- queue.setProfilingEnabled(true);
+ QVERIFY(!context.defaultCommandQueue().isProfilingEnabled());
+
+ QCLCommandQueue queue =
+ context.createCommandQueue(CL_QUEUE_PROFILING_ENABLE);
QVERIFY(queue.isProfilingEnabled());
+ context.setCommandQueue(queue);
QCLVector<float> vector1 = context.createVector<float>(20000);
for (int index = 0; index < vector1.size(); ++index)
@@ -433,8 +435,7 @@ void tst_QCL::eventProfiling()
QVERIFY(event.runTime() >= event.submitTime());
QVERIFY(event.finishTime() >= event.runTime());
- queue.setProfilingEnabled(false);
- QVERIFY(!queue.isProfilingEnabled());
+ context.setCommandQueue(context.defaultCommandQueue());
}
// Test QCLSampler.